package com.sca4cloud.sca;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.client.RestTemplate;

import com.sca4cloud.sca.common.data.mybatis.MybatisPlusConfiguration;
import com.sca4cloud.sca.common.security.annotation.EnableScaResourceServer;

import springfox.documentation.swagger2.annotations.EnableSwagger2;

//import com.sca4cloud.sca.common.datasource.annotation.EnableDynamicDataSource;
//@EnableDynamicDataSource
@EnableAsync
@SpringBootApplication(exclude = { MongoAutoConfiguration.class, MybatisPlusConfiguration.class })
@EnableFeignClients(basePackages = { "com.sca4cloud.sca.feign" })
@EnableScaResourceServer
@EnableSwagger2
@MapperScan({ "com.sca4cloud.sca.**.mapper", "com.dstz.**.dao","com.dstz.**.mapper" })
@ComponentScan(basePackages = { "com.sca4cloud.sca", "com.dstz" })
public class SbaServiceApplication {
	public static void main(String[] args) {
		SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
		SpringApplication.run(SbaServiceApplication.class, args);
	}
	
	@Bean("balancedRestTemplate")
	@LoadBalanced
	public RestTemplate balancedRestTemplate() {
		return new RestTemplate();
	}
	
}
